/**
 * DistrictMapper.java 
 * Copyright © 2015-3015, 杭州泊享网络科技有限公司
 * 
 * @author Liu Tao
 * @create 2013年8月14日
 */
package com.pshare.artemis.basic.mapper;

import java.util.List;

import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import com.pshare.framework.mapper.BaseMapper;
import com.pshare.artemis.basic.bean.District;

@Repository
public interface DistrictMapper extends BaseMapper<Integer, District> {

	public List<District> queryAll();
	
	public List<District> queryByCityId(int cityId);
	
	public Integer getCityIdByDistrictId(int districtId);
	
	/**
	 * 根据ID读取地区信息
	 * @param id
	 * @return District
	 */
	@Select("select * from tbl_base_district where id = #{id}")
	public District get(@Param("id") Integer id);
	
	/**
	 * 根据名称查找区县ID
	 * @param name
	 * @param cityId
	 * @return Integer
	 */
	@Select("select id from tbl_base_district where name like #{name} '%' and city_id = #{cityId}")
	public Integer findIdByName(@Param("name") String name, @Param("cityId") Integer cityId);
	
	@Select("select * from tbl_base_district where name like #{name} '%' and city_id = #{cityId}")
	public District findByName(@Param("name") String name, @Param("cityId") Integer cityId);
	
}
